
/**
 * Created by Administrator on 2018/7/30 0030.
 */
$(window).ready(function(){
    var textHeight = $(window).height() - $(".top-text").height();
    var scrollTop = $(".real-sc-right").scrollTop();
    var arr = [1,2,3,4,5]
    var Array = [];
    for(var i=1;i<6;i++){
        Array.push($(".sc-text1:nth-child("+i+")").offset().top);
    }
    $(".real-sc-right").scroll(function(){
        arr.forEach(function(item,index){
            if(((scrollTop+textHeight)>=$(".sc-text1:nth-child("+item+")").offset().top)&&((scrollTop+textHeight)<$(".sc-text1:nth-child("+(item+1)+")").offset().top)){
                $(".sc-change-list ul li").removeClass("active")
                $(".sc-change-list ul li:nth-child("+item+")").addClass("active")
            }
        });
    });
    console.log(Array)
    $("#change_list>li").click(function(){
        var indexNum = $(this).index();
        var scrollHeight = Array[indexNum]-textHeight
        $(".real-sc-right").scrollTop(scrollHeight)
    })
});